package com.qing.springbootinit.utils;

import org.springframework.stereotype.Component;

import java.lang.reflect.Field;

// * @author <a href="https://github.com/qingfengzy">qingfengzy</a>

@Component
public class EnumReflectionUtils {
    public static void setEnumField(Enum<?> enumConstant, String fieldName, Object newValue) throws Exception {
        Field field = enumConstant.getClass().getDeclaredField(fieldName);
        field.setAccessible(true);
        field.set(enumConstant, newValue);
    }
}
